<?php

class general {
    function ketnoi($query){
        $connect = mysql_connect("localhost","root","vertrigo");
        mysql_select_db("docs",$connect);
        mysql_query("SET character_set_result_utf8");
        $ret = mysql_query($query,$connect);
        $data = array();
        while ($row = mysql_fetch_assoc($ret)){
            $data[] = $row;
        }
        return $data;
    }
    function ketnoi1($query){
        $connect = mysql_connect("localhost","root","vertrigo");
        mysql_select_db("docs",$connect);
        mysql_query("SET character_set_result_utf8");
        mysql_query($query,$connect);
    }
    function xemhet($noixem){
        $query = "SELECT * FROM ".$noixem;
        return $this->ketnoi($query);
    }
    function xem($noixem,$canxem){
        $query = "SELECT * FROM ".$noixem." WHERE ".$canxem;
        return $this->ketnoi($query);
    }
    function them($noithem,$canthem){
        $query = "INSERT INTO ".$noithem." VALUES ('".$canthem."')";
        $this->ketnoi1($query);
    }
}
